package com.missilike.api.controller;

import com.alibaba.fastjson.JSON;
import com.missilike.core.result.CommonResult;
import com.missilike.core.service.IBaiduMapService;
import com.missilike.core.utils.ResultUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/api/baidu/map")
public class BaiDuMapController {

    private final IBaiduMapService baiduMapService;

    public BaiDuMapController(IBaiduMapService baiduMapService) {
        this.baiduMapService = baiduMapService;
    }

    @ApiOperation(value = "getAddress", notes = "获取当前位置")
    @RequestMapping(value = "/getAddress", method = RequestMethod.GET, produces = "application/json")
    @ResponseBody
    public CommonResult getAddress(@RequestParam String ip){
        log.info("Start to execute /api/baidu/map/getAddress body request={}",ip);
        Object object= baiduMapService.getAddress(ip);
        log.info("Start to execute /api/baidu/map/getAddress responese={}", object);
        return ResultUtils.ok(object);
    }
}
